<?php
$this->Html->addCrumb('Image Gallery', '/image-gallery');
if(isset($categoryInfo) && !empty($categoryInfo)) {
  $this->Html->addCrumb($categoryInfo['Category']['name']);
}
//CSS
echo $this->Html->css(array('tws-framework','prettyPhoto-min'), false);
//Javascript
echo $this->Html->script(array('plugins/jquery.prettyPhoto-min'), false);
$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){
          $("a[rel^=\'photo\']").prettyPhoto({theme: \'dark_rounded\', social_tools:false, deeplinking : false});
        });
       ';
$this->Html->scriptEnd();
?>

<h1 class="pageTitle">Image Gallery</h1>

<?php if(isset($categoryInfo) && !empty($categoryInfo)) {
  echo '<h2 id="albumCategoryHeader">'.$categoryInfo['Category']['name'].'</h2>';
}?>


<?php
  if (isset($albumResults) && !empty($albumResults)) {
    $count=0;
    foreach ($albumResults as $rec) {
      echo '<div class="photoAlbum">';
      $picCount = 0;
      foreach($rec['Photo'] as $photo) {
        if ($picCount===0){
          echo '<a href="'.Configure::read('App.pathPrefix').'/app/webroot/img/'.$photo['image_path'].'" class="firstPic" rel="photo[pp_gal'.$count.']" title="'.$photo['caption'].'">'.$this->Html->image($photo['image_path'], array("alt"=>$rec['Album']['name'], "title"=>"Click to view this album")).'</a>';
        } else {
          echo '<a href="'.Configure::read('App.pathPrefix').'/app/webroot/img/'.$photo['image_path'].'" rel="photo[pp_gal'.$count.']" title="'.$photo['caption'].'">'.$this->Html->image($photo['image_thumb_path'], array("alt"=>$rec['Album']['name'])).'</a>';
        }
        $picCount++;
      }
      echo '<div class="photoAlbumTitle"><span class="albumTitleText">'.$rec['Album']['name'].'</span></div>';
      echo '</div>';
      $count++;
      if($count!==0 && $count%2==0) {
        echo '<div class="clear"></div>';
      }
    }
    echo $this->element('main_pagination');
  }
?>